<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%-- 
    Document   : myBasket
    Created on : 05.02.2012, 05:21:27
    Author     : alexander
--%>

<%@page import="DAO.ImmoDAO"%>
<%@page import="java.util.Iterator"%>
<%@page import="Classes.Immo"%>
<%@page import="java.util.Vector"%>
<%@page import="Classes.ShoppingChart"%>
<%@page import="java.util.Date"%>
<%@page import="java.util.Calendar"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="UTF-8"%>
<link rel="stylesheet" type="text/css" href="betaDesign.css">
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>

     <div id="container">
        <h1>Ginzt-Immo - Geschenkt ist noch zu teuer</h1>
 <div id="left">        
            <%if (session.getAttribute("sessionUserID")==null) {%>
            
           <form method="post" action="UserManager" name="formular">
		<h5>User-Login:</h5><input name="userAlias">
		<h5>Password:</h5><input name="userPassword" type="password">
                <input type="hidden" name="Quelle" value="UserLogin">
            <input name="login" value="login" type="submit"><p></p>
	<h1><a class="menu" href="createNewUser.jsp">Noch nicht registriert? - Let's go</a></h1>
	</form>
            
            <%}else {%>
            <h5>Hallo <%=(String)session.getAttribute("sessionUserFirstName")%> <%=(String)session.getAttribute("sessionUserLastName")%></h5>
            <h5>Ihre E-Mail-Adresse:</h5> 
            <h5><%=(String)session.getAttribute("sessionUserEMail")%></h5>
        
            <h5>Sie sind online seit:<%=(String)session.getAttribute("createdAT")%></h5>
            
            <br></br>
            
            <form method="post" action="UserManager" name="formular">
                <input type="hidden" name="Quelle" value="UserLogout">
                <input name="logout" value="logout" type="submit"><p></p>
            </form> 
            <h1><a class="menu" href="persHist.jsp">Ihr Benutzerkonto</a></h1>
            <h1><a class="menu" href="myBasket.jsp">Ihr Warenkorb</a></h1>
            <h1><a class="menu" href="addNewImmo.jsp">Immobilie hinzufügen</a></h1>
            <h1><a class="menu" href="index.jsp">zur Hauptseite</a></h1>
            

            
            <h22>Angebote</h22>
            <h1><a class="menu" href="immoCatalog.jsp">Alle Immobilien</a></h1>
            <!--
            <h1><a class="menu" href="addNewCar.jsp">Häuser</a></h1>
            <h1><a class="menu" href="addNewCar.jsp">Wohnungen</a></h1>
            <h1><a class="menu" href="addNewCar.jsp">Grundstücke</a></h1>
             -->

            <h1><a class="menu" href="immoCatalogRent.jsp">Miete</a></h1>
            <h1><a class="menu" href="immoCatalogSale.jsp">Kauf</a></h1>
            
            <h22>Referenzen</h22>
            <h1><a class="menu" href="immoCatalogSold.jsp">Verkaufte Immobilien</a></h1>
            
            <h22>Suche</h22>
            <form method="post" action="SearchManager" name="formular">
                <h1><input name="searchString"/></h1>
                <input name="search" value="Finden" type="submit">
            </form>

            <%}%>
            
        </div>
        <div id="content">
            
         <%       
        ShoppingChart myShoppingChart = (ShoppingChart)session.getAttribute("sessionBasket");
        Vector<Immo> myImmoBasket = myShoppingChart.getImmoInTheBasket();
        Iterator iter = myImmoBasket.iterator();
        ImmoDAO newImmoDAO = new ImmoDAO();
        int i = 0;
        %>   
            
            
         <h1>Warenkorb</h1>
         <h2>Ihre ausgewählten Immobilien im Warenkorb</h2>
         <br></br>
         <h41>Im Warenkorb befinden sich derzeit <%=myImmoBasket.size()%> Immobilien</h41>
         <br></br>
         
         <table border="0">
             <tr>
                    <td><h41>Immobilie</h41></td>
                    <td><h41>Preis</h41></td>
                    <td><h41>Provision</h41></td>
                    <td></td>
             </tr>
             
       <form method="post" action="BuyManager" name="formular">
        <%

        
        while (iter.hasNext()){
            Immo newImmo = new Immo();
            newImmo = (Immo)iter.next();
            i++;
            if (!(newImmo.isIsSold())) {%>
            <tr>
                <td><h41><%=newImmo.getImmoHeadline()%></h41></td>
                <td><h41><%=newImmo.getPrice()%> EUR</h41></td>    
                <td><h41><%=newImmo.getPrice()*0.03%> EUR</h41></td>
                <%String checkboxName = "immo"+i;%>
                <td><h41><input type="checkbox" name="<%=checkboxName%>" value="<%=newImmo.getImmoID()%>">Auswählen<br></h41></td>  
         </tr>
            <%
                   }}

            %>
            
            
            
            
            </table>  
            <% if(myImmoBasket.size()>0) { %>
            <h2>Ausgewählte Immobilien kaufen ... </h2>
            <br></br>
            <br></br>
              
                <input type="hidden" name="anzahlAusgewählterImmobilien" value="<%=i%>">
 
            
            
            
            
            
            
            
            <% } else{
            
            }%>
                <input type="hidden" name="anzahlImmobilien" value="<%=i%>">
                <input type="hidden" name="userAlias" value="<%=(String)session.getAttribute("sessionUserAlias")%>">
                <input type="hidden" name="userPwd" value="<%=(String)session.getAttribute("sessionUserPwd")%>">
                <input type="hidden" name="buyer" value="<%=session.getAttribute("sessionUserID")%>">   
                <input type="hidden" name="absender" value="kaufen">
            
                <input name="kaufen" value="ausgewählte Immobilien kaufen" type="submit"><p></p>
            </form>
            
            <br></br>
        </div>
        
    </body>
</html>
